var BROWSER = (function () {
    'use strict';

    var Browser = {};

    function isIe() {
        return window.msAnimationStartTime !== undefined;
    }

    function isWebkit() {
        return document.body.style.webkitAnimation !== undefined;
    }

    function isMozilla() {
        return window.mozAnimationStartTime !== undefined;
    }

    Browser.correctlyCapturesProgramInfoLog = function () {
        return !isMozilla();
    };

    Browser.supportsStyledConsoleLogging = function () {
        return isWebkit();
    };

    Browser.canCaptureCustomStackTraces = function () {
        return Error.captureStackTrace !== undefined;
    };

    Browser.stackTrace = function (f) {
        var trace, old = Error.prepareStackTrace, failure;
        if (Error.captureStackTrace !== undefined && typeof f === 'function') {
            Error.prepareStackTrace = function (e, s) {
                var m = [], i, cs, csf;
                for (i = 1; i < s.length; i += 1) {
                    cs = s[i];
                    csf = {
                        file: cs.getFileName(),
                        fn : cs.getFunctionName() || '',
                        line : cs.getLineNumber()
                    };
                    if (f(e, csf, m)) {
                        break;
                    }
                }
                return m.join('\n');
            };
            failure = {};
            Error.captureStackTrace(failure);
            trace = failure.stack;
            Error.prepareStackTrace = old;
        } else {
            try {
                throw new Error();
            } catch (e) {
                trace = e.stack;
            }
        }
        return trace;
    };

    Browser.isIe = isIe;
    Browser.isWebkit = isWebkit;
    Browser.isMozilla = isMozilla;

    return Browser;
}());
